/* eslint-disable @iceworks/best-practices/recommend-polyfill */
import { Drawer, Tab } from '@alifd/next';
import { t } from '@lingui/macro';
import React from 'react';
import { useParams } from 'react-router';

import CcOrderForm from './components/CcOrderForm';

export default function OrderView() {
  const { id } = useParams();
  /**
   * 订单类型： 1 - 包车； 2 - 专线； 3 - 巴士 4 - 拼车 5 - 专线任务
   */
  let orderType = 1;
  if (id?.startsWith('SCO')) orderType = 2;
  if (id?.startsWith('BUS')) orderType = 3;
  if (id?.startsWith('RS')) orderType = 4;
  if (id?.startsWith('ZXR')) orderType = 5;

  const handleClose = () => {
    window.parent.postMessage('closed', '*');
  };

  return (
    <div style={{}}>
      <Drawer
        closeMode={[]}
        visible
        animation={false}
        width="100%"
        style={{ maxWidth: '100%', border: 0 }}
        onClose={handleClose}
      >
        {orderType === 1 &&
          <CcOrderForm orderId={id} modal={['view']} onCancel={() => handleClose()} />}
      </Drawer>

    </div>
  );
}
